package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.ConfigOperatePositionOperate;

public class ConfigOperatePositionProcess {

    DriverBase driver;
    ConfigOperatePositionOperate coph;
    public ConfigOperatePositionProcess(DriverBase driver){
        this.driver = driver;
        coph = new ConfigOperatePositionOperate(driver);
    }

    //添加运营位
    public void addOperatePosition(String positionName,String sign,String num){

        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //点击运营管理
        coph.clickOperateManageMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击配置运营位
        coph.clickConfigOperatePositionMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击添加
        coph.clickAddBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //输入名称
        coph.inputOperatePosiName(positionName);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //输入标识
        coph.inputOperatePosiSign(sign);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //上传图片按钮
        coph.clickOperatePosiImgBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //执行上传脚本
        coph.execUpImgScript();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击运营分类下拉框
        coph.clickOperateCateDownList();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //选择分类
        coph.selectOperateCategory();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //选择所属页面
        coph.selectBelongToPage();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //输入推荐数量
        coph.inputRecommondNum(num);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击确定按钮
        coph.clickConfirmBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }


    public boolean addOperatePositionSuccess(String positionName){
        String name = coph.getFirstOperaPosition().getText();
        if(name.contains(positionName)){
            return true;
        }else {
            return false;
        }
    }


    //删除运营位
    public void delOperatePosition(){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //点击第一条“删除”按钮
        coph.clickFirstDelBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击“确定”按钮
        coph.clickDelConfirmBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    public boolean delOperaPositionSuccess(String positionName){

        if(coph.getFirstOperaPosition().getText().contains(positionName)){
            return false;
        }else {
            return true;
        }

    }


}
